/**
* Copyright (c) By zengqh.
*
* This program is just for fun or demo, in the hope that it  
* will be useful, you can redistribute it and/or modify freely.
*
* Time: 2013/04/30
* File: RenderStates.cpp
* Blog: http://www.cnblogs.com/zengqh/
**/

#include "RenderStates.h"

namespace HY
{
RenderStates::RenderStates()
{
	render_states_[RenderState::FillMode] = Fill::Solid;
	render_states_[RenderState::CullMode] = Cull::CCW;
	render_states_[RenderState::ZEnable] = true;
	render_states_[RenderState::ZWriteEnable] = true;
	render_states_[RenderState::ZFunc] = Compare::LessEqual;
	render_states_[RenderState::ZBias] = FloatToUint32(0.0f);
	render_states_[RenderState::BlendEnable] = false;
	render_states_[RenderState::SrcBlendFunc] = BlendFunc::SrcAlpha;
	render_states_[RenderState::SrcBlendFunc] = BlendFunc::InvSrcAlpha;
	render_states_[RenderState::LineWidth] = FloatToUint32(1.0f);
}

RenderStates::~RenderStates()
{

}

uint32 RenderStates::getFillMode() const
{
	return render_states_[RenderState::FillMode];
}

void RenderStates::setFillMode(uint32 val)
{
	render_states_[RenderState::FillMode] = val;
}

uint32 RenderStates::getCullMode() const
{
	return render_states_[RenderState::CullMode];
}

void RenderStates::setCullMode(uint32 val)
{
	render_states_[RenderState::CullMode] = val;
}

bool RenderStates::getZEnable() const
{
	return render_states_[RenderState::ZEnable];
}

void RenderStates::setZEnable(bool val)
{
	render_states_[RenderState::ZEnable] = val;
}

bool RenderStates::getZWriteEnable() const
{
	return render_states_[RenderState::ZWriteEnable];
}

void RenderStates::setZWriteEnable(bool val)
{
	render_states_[RenderState::ZWriteEnable] = val;
}

uint32 RenderStates::getZFunc() const
{
	return render_states_[RenderState::ZFunc];
}

void RenderStates::setZFunc(uint32 val)
{
	render_states_[RenderState::ZFunc] = val;
}

float RenderStates::getZBias() const
{
	return Uint32ToFloat(render_states_[RenderState::ZBias]);
}

void RenderStates::setZBias(float value)
{
	render_states_[RenderState::ZBias] = FloatToUint32(value);
}

bool RenderStates::getBlendEnable() const
{
	return render_states_[RenderState::BlendEnable];
}

void RenderStates::setBlendEnable(bool val)
{
	render_states_[RenderState::BlendEnable] = val;
}

uint32 RenderStates::getSrcBlendFunc() const
{
	return render_states_[RenderState::SrcBlendFunc];
}

void RenderStates::setSrcBlendFunc(uint32 val)
{
	render_states_[RenderState::SrcBlendFunc] = val;
}

uint32 RenderStates::getDstBlendFunc() const
{
	return render_states_[RenderState::DstBlendFunc];
}

void RenderStates::setDstBlendFunc(uint32 val)
{
	render_states_[RenderState::DstBlendFunc] = val;
}

float RenderStates::getLineWidth() const
{
	return Uint32ToFloat(render_states_[RenderState::LineWidth]);
}

void RenderStates::setLineWidth(float val)
{
	render_states_[RenderState::LineWidth] = FloatToUint32(val);
}

uint32 RenderStates::get(uint32 render_state) const
{
	return render_state[render_state];
}

bool RenderStates::set(uint32 render_state, uint32 val)
{
	render_state[render_state] = val;
}

}